package com.example.vieweventdemo;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;

import com.example.vieweventdemo.animotion.AnimotionActivity;
import com.example.vieweventdemo.eventintercept.TestActivity;

public class MainActivity extends AppCompatActivity {
    private static final String TAG = "MainActivity";

    private TestView tv;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        tv = (TestView) findViewById(R.id.tv);
        tv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                tv.smoothScrollTo(500, 500);
                /*Log.e(TAG, "left:" + tv.getLeft());
                Log.e(TAG, "right:" + tv.getRight());
                Log.e(TAG, "top:" + tv.getTop());
                Log.e(TAG, "bottom:" + tv.getBottom());

                Log.e(TAG, "X:" + tv.getX());
                Log.e(TAG, "Y:" + tv.getY());
                Log.e(TAG, "translationX:" + tv.getTranslationX());
                Log.e(TAG, "translationY:" + tv.getTranslationY());*/
            }
        });

        findViewById(R.id.btn_animotion).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(MainActivity.this, AnimotionActivity.class);
                startActivity(intent);
            }
        });

        findViewById(R.id.btn_handler_postdelayed).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Log.e(TAG, "onClick: " );
                startActivityForResult(new Intent(MainActivity.this, HandlerPostDelayedActivity.class), 100);
            }
        });

        findViewById(R.id.btn_thread_sleep).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(new Intent(MainActivity.this, ThreadSleepActivity.class));
            }
        });

        findViewById(R.id.btn_event_intercept).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(new Intent(MainActivity.this, TestActivity.class));
            }
        });
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        Log.e(TAG, "onActivityResult: requestCode:" + requestCode + ",resultCode:" + resultCode);
        super.onActivityResult(requestCode, resultCode, data);
    }
}
